NW 8 - Opening AppleTalk

Networking

Written by: Mark Bennett February 1989

This Technical Note describes the most effective, safe, and compatible way to open the AppleTalk drivers, .MPP and .ATP.

The process of opening the AppleTalk drivers, .MPP and .ATP, can be greatly simplified. The AppleTalk Manager chapters of Inside Macintosh describe the calls MPPOpen and ATPLoad for use by high-level languages. They also describe the process of examining low-memory globals SPConfig and PortBUse before calling _Open for assembly language use of AppleTalk.

Starting with the 128K ROM, the .MPP driver already has all the code built in for checking the low-memory globals SPConfig and PortBUse before trying to complete the _Open call. Furthermore, the .MPP driver will automatically open the .ATP driver as part of its opening process. Therefore, since all of the required checks are made inside the driver itself, we recommend that a simple _Open call be made to the .MPP driver when you need to use AppleTalk. In a high-level language like Pascal, this call would look like the following:

	result := OpenDriver('.MPP', refnum);

In C:

	result = OpenDriver("\p.MPP", &refnum);

And in assembly language:

openAT	SUB.W	#ioQElSize,SP	; Make space for paramblock on stack 
			; since _Open is always synchronous.			;  Using .W is slightly more efficient 
			; and is safe since ioQElSize is small.
	MOVE.L	SP,A0	; Point A0 to paramblock.
	LEA	mppName,A1	; Point A1 to driver name.
	MOVE.L	A1,ioFileName(A0); Put pointer to name in paramblock.
	CLR.B	ioPermssn(A0)	; Clear so won't look like OpenDeskAcc.
_Open
	MOVE.W	ioRefNum(A0),D1	;You might want this later. Who knows?
	ADD.W	#ioQElSize,SP	; Reclaim space on stack.
	RTS		; D0 contains result code.

mppName	DC.B	4
	DC.B	'.MPP'

By using just the simple _Open call to the .MPP driver, you can ensure that your code will be compatible with future versions of AppleTalk that might not make use of low-memory globals.

Further Reference: